<?php
$curPage = curPageName();

class MenuItem {
    public $url, $name;
    function __construct($u, $n) {
        $this->url = $u;
        $this->name = $n;
    }
    function __destruct() {
    }
    function printLI($curPage) {
//        echo $curPage . " vs " . $this->url . "<br>";
//        if($curPage == $this->url) echo "WINNER WINNER CHICKEN DINNER <br>";
        if($curPage == $this->url) {
            echo "<li id=\"selected\"><a href=\"" . $this->url . "\">" . $this->name . "</a></li>";
        } else {
            echo "<li><a href=\"" . $this->url . "\">" . $this->name . "</a></li>";
        }
        echo "\n";
    }

}

$menuItems = array(
    new MenuItem("index.php", "Home"),
    new MenuItem("tempMenu.php", "Menu Testing"),
    new MenuItem("http://net.tutsplus.com/", "Nettuts"),
    new MenuItem("contact.php", "Contact"),
    new MenuItem("login.php", "Login"),
    new MenuItem("register.php", "Register"),
);

echo "
<div id=\"menu\">
  <ul id=\"nav\">";

$pageFound = false;
foreach($menuItems as $cur) {
    if($cur->url == $curPage) $pageFound = true;
}
if(!$pageFound) {
    $curPage = "index.php";
}

foreach($menuItems as $cur) {
    $cur->printLI($curPage);
}

echo "</ul>
</div>";
?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"
    type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"
    type="text/javascript"></script>
<script src="js/jquery.menuEffect.js"
    type="text/javascript"></script>

<script type="text/javascript">
    $('#nav').menuEffect();
</script>
